home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / t410x.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  6.9 KB  |  300 lines

  1. /*
  2.  * $Id: t410x.trm,v 1.7 1995/12/20 21:48:13 drd Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - t410x.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports: Tektronix 410x and 420x series terminals
  25.  *
  26.  * AUTHORS
  27.  *   Colin Kelley, Thomas Williams
  28.  * 
  29.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  30.  * 
  31.  */
  32.  
  33. /* Tektronix 410X and 420X driver written by Cary D. Renzema.
  34.  * email address: caryr@mxim.com
  35.  *
  36.  * I've tested this driver on the following terminals: 4106, 4107A, 4109
  37.  * and 4207.  It should work, without editing, on other terminals in the
  38.  * 410x and 420x families.  It will probably need to be changed to work
  39.  * on a 4105 (screen size and character rotation are two guesses).  This
  40.  * file can also be used as a start for a 411x driver.
  41.  *
  42.  * Cary R.
  43.  * April 5, 1990
  44.  */
  45.  
  46. /*
  47.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  48.  */
  49.  
  50. #ifndef GOT_DRIVER_H
  51. #include "driver.h"
  52. #endif
  53.  
  54. #ifdef TERM_REGISTER
  55. register_term(tek410x)
  56. #endif
  57.  
  58. #ifdef TERM_PROTO
  59. TERM_PUBLIC void T410X_init __P((void));
  60. TERM_PUBLIC void T410X_reset __P((void));
  61. TERM_PUBLIC void T410X_graphics __P((void));
  62. TERM_PUBLIC void T410X_text __P((void));
  63. TERM_PUBLIC void T410X_move __P((unsigned int x, unsigned int y));
  64. TERM_PUBLIC void T410X_vector __P((unsigned int x, unsigned int y));
  65. TERM_PUBLIC void T410X_point __P((unsigned int x, unsigned int y, int number));
  66. TERM_PUBLIC void T410X_linetype __P((int linetype));
  67. TERM_PUBLIC void T410X_put_text __P((unsigned int x, unsigned int y, char str[]));
  68. TERM_PUBLIC int T410X_text_angle __P((int ang));
  69. #define T410XXMAX 4095
  70. #define T410XYMAX 3131
  71.  
  72. #define T410XVCHAR    71
  73. #define T410XHCHAR    51
  74. #define T410XVTIC    36
  75. #define T410XHTIC    36    
  76. #endif /* TERM_PROTO */
  77.  
  78. #ifndef TERM_PROTO_ONLY
  79. #ifdef TERM_BODY
  80. void T410X_encode_x_y __P((unsigned int x, unsigned int y));
  81. void T410X_encode_int __P((int number));
  82.  
  83.  
  84. static int T410X_angle=0;
  85.  
  86. TERM_PUBLIC void T410X_init()
  87. {
  88.     (void) fprintf(outfile, "\033%%!0\033MN0\033MCB7C;\033MQ1\033MT1");
  89.     (void) fprintf(outfile, "\033MG1\033RK!\033SK!\033LZ\033%%!1");
  90. /*
  91.      1. set tek mode
  92.      2. set character path to 0 (characters placed equal to rotation)
  93.      3. set character size to 59 height
  94.      4. set character precision to string
  95.      5. set character text index to 1
  96.      6. set character write mode to overstrike
  97.      7. clear the view
  98.      8. clear the segments
  99.      9. clear the dialog buffer
  100.     10. set ansi mode
  101. */
  102.     (void) fflush(outfile);
  103. }
  104.  
  105.  
  106. TERM_PUBLIC void T410X_reset()
  107. {
  108.     (void) fprintf(outfile, "\033%%!0\033LZ\033%%!1");
  109. /*
  110.     1. set tek mode
  111.     2. clear the dialog buffer
  112.     3. set ansi mode
  113. */
  114.     (void) fflush(outfile);
  115. }
  116.  
  117.  
  118. TERM_PUBLIC void T410X_graphics()
  119. {
  120.     (void) fprintf(outfile, "\033%%!0\033\014\033LV0");
  121. /*
  122.     1. set tek mode
  123.     2. clear the screen
  124.     3. set dialog area invisible
  125. */
  126.     (void) fflush(outfile);
  127. }
  128.  
  129. TERM_PUBLIC void T410X_text()
  130. {
  131.     (void) fprintf(outfile, "\033LV1\033%%!1");
  132. /*
  133.     1. set dialog area visible
  134.     2. set ansi mode
  135. */
  136.     (void) fflush(outfile);
  137. }
  138.  
  139.  
  140. TERM_PUBLIC void T410X_move(x, y)
  141. unsigned int x, y;
  142. {
  143.     (void) fprintf(outfile, "\033LF");
  144.     (void) T410X_encode_x_y(x, y);
  145.     (void) fflush(outfile);
  146. }
  147.  
  148.  
  149. TERM_PUBLIC void T410X_vector(x, y)
  150. unsigned int x, y;
  151. {
  152.     (void) fprintf(outfile, "\033LG");
  153.     (void) T410X_encode_x_y(x, y);
  154.     (void) fflush(outfile);
  155. }
  156.  
  157.  
  158. TERM_PUBLIC void T410X_point(x, y, number)
  159. unsigned int x, y;
  160. int number;
  161. {
  162.     (void) fprintf(outfile, "\033MM");
  163.     (void) T410X_encode_int(max(number, 0)%11);
  164.     (void) fprintf(outfile, "\033LH");
  165.     (void) T410X_encode_x_y(x, y);
  166.     (void) fflush(outfile);
  167. }
  168.  
  169.  
  170. TERM_PUBLIC void T410X_linetype(linetype)
  171. int linetype;
  172. {
  173.     switch (linetype) {
  174.         case -1:
  175.             (void) fprintf(outfile, "\033ML5");
  176.             break;
  177.         case -2:
  178.             (void) fprintf(outfile, "\033ML?");
  179.             break;
  180.         default:
  181.             (void) fprintf(outfile, "\033ML");
  182.             (void) T410X_encode_int(linetype%14+2);
  183.             break;
  184.     }
  185.     (void) fprintf(outfile, "\033MV");
  186.     (void) T410X_encode_int(max(linetype, 0)%8);
  187.     (void) fflush(outfile);
  188. }
  189.  
  190.  
  191. TERM_PUBLIC void T410X_put_text(x, y, str)
  192. unsigned int x, y;
  193. char str[];
  194. {
  195.  
  196.     if (T410X_angle == 0) {
  197.         (void) T410X_move(x, y-T410XVCHAR/2+6);
  198.         (void) fprintf(outfile, "\033MR00");
  199.     } else {
  200.         (void) T410X_move(x+T410XHCHAR/2-6, y);
  201.         (void) fprintf(outfile, "\033MRE:0");
  202.     }
  203.     (void) fprintf(outfile, "\033LT");
  204.     (void) T410X_encode_int(strlen(str));
  205.     (void) fputs(str, outfile);
  206.     (void) fflush(outfile);
  207. }
  208.  
  209. TERM_PUBLIC int T410X_text_angle(ang)
  210. int ang;
  211. {
  212.  
  213.     T410X_angle = ang;
  214.     return(TRUE);
  215. }
  216.  
  217. /* These last two routines are based on fortran code found in the
  218.  * 4106/4107/4109/CX PROGRAMMERS manual.
  219.  */
  220.  
  221. void T410X_encode_x_y(x, y)
  222. unsigned int x, y;
  223. {
  224.     static char chix=0, chiy=0, cloy=0, ceb=0;
  225.  
  226.     register unsigned int hix, lox, hiy, loy, eb, lx, ly;
  227.  
  228.     lx = (x <= T410XXMAX) ? x : T410XXMAX;
  229.     ly = (y <= T410XYMAX) ? y : T410XYMAX;
  230.  
  231.     hix = lx/128 + 32;
  232.     lox = (lx/4)%32 + 64;
  233.     hiy = ly/128 + 32;
  234.     loy = (ly/4)%32 + 96;
  235.     eb = (ly%4)*4 + lx%4 + 96;
  236.  
  237.     if (chiy != hiy) (void) putc(hiy, outfile);
  238.     if (ceb != eb) (void) putc(eb, outfile);
  239.     if ((cloy!=loy) || (ceb!=eb) || (chix!=hix)) (void) putc(loy, outfile);
  240.     if (chix != hix) (void) putc(hix, outfile);
  241.     (void) putc(lox, outfile);
  242.  
  243.     chix = hix;
  244.     chiy = hiy;
  245.     cloy = loy;
  246.     ceb = eb;
  247. }
  248.  
  249.  
  250. void T410X_encode_int(number)
  251. int number;
  252. {
  253.     register unsigned int mag, hi1, hi2, lo;
  254.  
  255.     mag = abs(number);
  256.  
  257.     hi1 = mag/1024 + 64;
  258.     hi2 = (mag/16)%64 + 64;
  259.     lo = mag%16 + 32;
  260.  
  261.     if (number >= 0) lo += 16;
  262.  
  263.     if (hi1 != 64) (void) putc(hi1, outfile);
  264.     if ((hi2 != 64) || (hi1 != 64)) (void) putc(hi2, outfile);
  265.     (void) putc(lo, outfile);
  266.  
  267. }
  268.  
  269. #endif /* TERM_BODY */
  270.  
  271. #ifdef TERM_TABLE
  272.  
  273. TERM_TABLE_START(tek410x_driver)
  274.     "tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
  275.        T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
  276.        T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
  277.        T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
  278.        T410X_linetype, T410X_put_text, T410X_text_angle, 
  279.        null_justify_text, T410X_point, do_arrow, set_font_null
  280. TERM_TABLE_END(tek410x_driver)
  281.  
  282. #undef LAST_TERM
  283. #define LAST_TERM tek410x_driver
  284.  
  285. #endif /* TERM_TABLE */
  286. #endif /* TERM_PROTO_ONLY */
  287.  
  288. /*
  289.  * NAME: tek410x
  290.  *
  291.  * OPTIONS: none
  292.  *
  293.  * SUPPORTS: 410x and 420x family of Tektronix terminals
  294.  *
  295.  * Further Info: 
  296.  * This driver has been tested on the following terminals: 4106, 4107A, 4109
  297.  * and 4207.  It should work, without editing, on other terminals in the
  298.  * 410x and 420x families.  It probably won't work on a 4105. 
  299.  *
  300.  */